<!DOCTYPE html>
        <html lang="en">
        <head lang="en">
            <meta charset="UTF-8">
            <title>农村房地一体网络公示平台</title>
            <meta http-equiv="X-UA-Compatible" content="IE=edge">
            <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
            <meta name="format-detection" content="telephone=no">
            <meta name="renderer" content="webkit">
            <meta http-equiv="Cache-Control" content="no-siteapp" />
            <!--<link rel="alternate icon" type="image/png" href="assets/i/favicon.png">-->
            <link rel="stylesheet" href="assets/css/amazeui.min.css"/>
            <script src="assets/js/zepto.min.js?ver=1.1.3"></script>
            <script src="assets/js/amazeui.js"></script>
            <script src="assets/js/handlebars.min.js
"></script>
            <script src="assets/js/amazeui.widgets.helper.js"></script>
            <style>
                .header {
                    text-align: center;
                }
                .header h1 {
                    font-size: 200%;
                    color: #333;
                    margin-top: 30px;
                }
                .header p {
                    font-size: 14px;
                }
                .am-header-default .am-header-title{
                    margin: 0 0;
                }
                .am-form .am-checkbox-inline{
                    width: 100%;
                    margin-left: 0px;
                    padding-left: 25%;
                }
                .next-btn{
                    width: 100%;
                    background: #0e90d2;
                    color: #fff;
                }
                .title{
                    margin-top: 30px;
                }
            </style>
        </head>
<body>

<header data-am-widget="header" class="am-header am-header-default">
    <div class="am-header-left am-header-nav" style="visibility: hidden">
        <a href="#left-link" class="">
            <i class="am-header-icon am-icon-home"></i>
        </a>
    </div>
    <h1 class="am-header-title">
        <a href="#title-link">农村房地一体网络公示平台</a>
    </h1>
</header>
<div class="am-g">
    <div class="col-lg-6 col-md-8 col-sm-centered">
        <h2 class="title">4、意见反馈</h2>
        <hr>
        <form class="am-form">
            <fieldset>

                <div class="am-form-group">
                    <label class="am-checkbox-inline">
                        <input id ="gsxyzq" type="checkbox" value="gsxyzq" name="feedback" onclick="checkboxOnclick(this)">1、 公示信息正确
                    </label>
                    <label class="am-checkbox-inline">
                        <input id = "hjxxzq" type="checkbox" value="hjxxzq" name="feedback" onclick="checkboxOnclick(this)">2、 户籍信息有误
                    </label>
                    <label class="am-checkbox-inline">
                        <input id= "zdtyw" type="checkbox" value="zdtyw" name="feedback" onclick="checkboxOnclick(this)">3、 宗地图有误
                    </label>
                    <label class="am-checkbox-inline">
                        <input id = "hcfdtyw" type="checkbox" value="hcfdtyw" name="feedback" onclick="checkboxOnclick(this)">4、 房产分户图有误
                    </label>
                </div>

                <p style="padding-left: 15%"><button type="button" class="am-btn am-btn-default" style="width: 80%;
    padding-left: 10%;" onclick="submitFeecdBack()">提交</button></p>
            </fieldset>
        </form>
        <hr>

        <button  type="button" class="am-btn am-btn-default next-btn" onclick="prePage()" >上一页</button>
    </div>
</div>

<footer data-am-widget="footer" class="am-footer am-footer-default" data-am-footer="{  }">
    <div class="am-footer-miscs ">
        <p>
            <a href="#" title="诺亚方舟" target="_blank"></a>Powered by 四川省川核测绘地理信息有限公司</p>
    </div>
</footer>

<script src="js/jquery-3.4.1.js"></script>
<script src="js/axios.min.js"></script>
<script src="config.js"></script>
<script>
    var userInfo = GetQueryValue('userInfo');
    var obj = JSON.parse(userInfo);
    // 这个地方每次进来要重新加载一下数据，不然提交之后切换页面数据没变
    var url = config.loginUrl;
    var req = {
        hzxm : obj.hzxm,
        sfzhm : obj.sfzhm
    }
    axios({
        method:'get',
        url:url,
        params: req,
        timeout: 5000
    })
        .then(function(response) {
            if(response.status == 200){
                var data = response.data;
                if(data.status ==1){
                    alert(data.msg);
                }else{
                    var gsxyzq = data.data['gsxyzq'];
                    var hcfdtyw= data.data['hcfdtyw'];
                    var hjxxzq= data.data['hjxxzq'];
                    var zdtyw= data.data.zdtyw;
                    if(gsxyzq === 1){
                        $("#gsxyzq").attr("checked","true")
                    }
                    if(hcfdtyw === 1){
                        $("#hcfdtyw").attr("checked","true")
                    }
                    if(hjxxzq === 1){
                        $("#hjxxzq").attr("checked","true")
                    }
                    if(zdtyw === 1){
                        $("#zdtyw").prop("checked","true")
                    }
                }
            }
        })
        .catch(function (error) {
            console.log(error);
        });


    function checkboxOnclick(checkbox){
        if ( checkbox.checked == true){
           if(checkbox.id === "gsxyzq"){
               document.getElementById("hcfdtyw").checked = false
               document.getElementById("hjxxzq").checked = false
               document.getElementById("zdtyw").checked = false
           }else {
               document.getElementById("gsxyzq").checked = false
           }
        }
    }

    /**
     * [通过参数名获取url中的参数值]
     * 示例URL:http://htmlJsTest/getrequest.html?uid=admin&rid=1&fid=2&name=小明
     * @param  {[string]} queryName [参数名]
     * @return {[string]}           [参数值]
     */
    function GetQueryValue(queryName) {
        var query = decodeURI(window.location.search.substring(1));
        var vars = query.split("&");
        for (var i = 0; i < vars.length; i++) {
            var pair = vars[i].split("=");
            if (pair[0] == queryName) { return pair[1]; }
        }
        return null;
    }
    function submitFeecdBack(){
        var userInfoObj = JSON.parse(userInfo);
        obj = document.getElementsByName("feedback");
        var chekedarr = [];
        for (k in obj) {
            if (obj[k].checked) {
                chekedarr.push(obj[k].value)
            }
        }

        var req = {
            gsxyzq : chekedarr.includes("gsxyzq")?1:0,
            hcfdtyw  : chekedarr.includes("hcfdtyw")?1:0,
            hjxxzq:chekedarr.includes("hjxxzq")?1:0,
            zdtyw:chekedarr.includes("zdtyw")?1:0,
            sfzhm:userInfoObj.sfzhm
        }
        var url = config.feedBack;
        axios({
            method:'get',
            url:url,
            params: req,
            timeout: 5000
        })
            .then(function(response) {
                if(response.status == 200){
                    var data = response.data;
                    if(data.status ==0){
                        alert("反馈成功");
                        location.href="four.html?userInfo="+userInfo;
                    }else{
                        alert("反馈失败");
                    }
                }
            })
            .catch(function (error) {
                console.log(error);
            });
    }
    function prePage() {

        location.href="three.html?userInfo="+userInfo;
    }

</script>
</body>

</html>
